Generation of supplemental materials for the MRIQC paper

This notebook is associated to the paper:

Esteban O, Birman D, Schaer M, Koyejo OO, Poldrack RA, Gorgolewski KJ; MRIQC: Predicting Quality in Manual MRI Assessment Protocols Using No-Reference Image Quality Measures; bioRxiv 111294; doi:10.1101/111294.


In [ ]:
%matplotlib inline
%load_ext autoreload
%autoreload 2
import os.path as op
import numpy as np
import pandas as pd
from mriqc.viz import misc as mviz
from pkg_resources import resource_filename as pkgrf
outputs_path = '../../mriqc-data/'

In [ ]:
x_path = pkgrf('mriqc', 'data/csv/x_abide.csv')
y_path = pkgrf('mriqc', 'data/csv/y_abide.csv')
ds030_x_path = pkgrf('mriqc', 'data/csv/x_ds030.csv')
ds030_y_path = pkgrf('mriqc', 'data/csv/y_ds030.csv')

rater_types = {'rater_1': float, 'rater_2': float, 'rater_3': float}
mdata = pd.read_csv(y_path, index_col=False, dtype=rater_types)

sites = list(sorted(list(set(mdata.site.values.ravel().tolist()))))

In [ ]:
fig = mviz.raters_variability_plot(
    mdata, raters=['rater_1', 'rater_2', 'rater_3'], 
    rater_names=['Rater 1', 'Rater 2A', 'Rater 2B'],
    out_file=op.join(outputs_path, 'figures', 'suppl-fig02.pdf'),
    only_overlap=False)

In [ ]:
from sklearn.metrics import cohen_kappa_score
overlap = mdata[np.all(~np.isnan(mdata[['rater_2', 'rater_3']]), axis=1)]
y1 = overlap.rater_2.values.ravel().tolist()
y2 = overlap.rater_3.values.ravel().tolist()

fig = mviz.inter_rater_variability(y1, y2, raters=['Protocol A', 'Protocol B'],
                                   out_file=op.join(outputs_path, 'figures', 'suppl-intrarv.pdf'))

print("Cohen's Kappa %f" % cohen_kappa_score(y1, y2))

y1 = overlap.rater_2.values.ravel()
y1[y1 == 0] = 1

y2 = overlap.rater_3.values.ravel()
y2[y2 == 0] = 1
print("Cohen's Kappa (binarized): %f" % cohen_kappa_score(y1, y2))

In [ ]:
fig = mviz.plot_corrmat(x_path)

In [ ]:
fig = mviz.plot_histograms(x_path, y_path)